<template>
  <div>
    <img src="../assets/beijing.png" class="bg"/>
    <div id='login'>
      <div class='yuan'>
        <img style="width: 100%; height: 100% ; border-radius: 50%" src="../assets/logo.png">
      </div>
      <p style="text-align: center;color: red;position: relative;top: 80px" v-text="message"></p>
      <div class="input-username">
        <el-input placeholder="请输用户名" v-model="loginUser.username">
          <template slot="prepend"><i class="el-icon-user"></i></template>
        </el-input>
      </div>
      <div class="input-password">
        <el-input v-model='loginUser.password' placeholder="请输入密码" show-password>
          <template slot="prepend"><i class="el-icon-lock"></i></template>
        </el-input>
      </div>
      <div class="input-password">
          <el-button type='primary' @click='login()'>登录</el-button>
          <!--这里跳转了一个路由-->
          <el-button>
            <router-link to="/register">注册</router-link>
          </el-button>
      </div>
      <!--        <el-form-item prop='name'>-->
      <!--          <el-input v-model='loginUser.username' prefix-icon="el-icon-user" placeholder="请输入用户名"></el-input>-->
      <!--        </el-form-item>-->
      <!--        <p style="text-align: center;color: red">{{message}}</p>-->
      <!--        <el-form-item prop='pass'>-->
      <!--          <el-input v-model='loginUser.password' prefix-icon="el-icon-lock" placeholder="请输入密码"-->
      <!--                    show-password></el-input>-->
      <!--        </el-form-item>-->
      <!--        <el-form-item>-->
      <!--          <el-button type='primary' @click='login()'>登录</el-button>-->
      <!--          &lt;!&ndash;这里跳转了一个路由&ndash;&gt;-->
      <!--          <el-button>-->
      <!--            <router-link to="/register">注册</router-link>-->
      <!--          </el-button>-->
      <!--        </el-form-item>-->
      <!--      </el-form>-->
    </div>
  </div>
</template>

<script>
import {mapMutations} from 'vuex'

export default {
  data() {
    return {
      loginUser: {
        username: '16738254758',
        password: '123456'
      },
      rules: {
        name: [
          {required: true, message: '请输入用户名', trigger: 'blur'},
          {min: 1, max: 10, message: '请输入你的用户名', trigger: 'blur'}
        ],
        pass: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 1, max: 10, message: '密码为空！！！', trigger: 'blur'}
        ]
      },
      message: ""
    };
  },
  created() {
    this.clear()
  },
  methods: {
    ...mapMutations(['changeLogin']),
    clear() {
    },
    login() {
      this.$axios({
        url: 'http://localhost:9527/backstagesupporter/main/login',
        method: 'POST',
        data: this.loginUser
      })
          .then(res => {
            if (res.data.code == 200) {
              window.sessionStorage.setItem("auth", res.data.data)
              this.$router.push({path: '/main'})
            } else {
              this.message = res.data.message
            }
          })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>
<style lang="scss" scoped>
#login {
  background-color: white;
  width: 450px !important;
  height: 300px !important;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
}

.input-username {
  width: 400px;
  height: 40px;
  margin: 0 auto;
  margin-top: 100px;
}
.input-password {
  width: 400px;
  height: 40px;
  margin: 0 auto;
  margin-top: 10px;
}

.yuan {
  width: 135px;
  height: 130px;
  border-radius: 50%;
  background: #EEEEEE;
  border: 10px solid white;
  position: absolute;
  top: -30%;
  left: 34%;
  z-index: 1;
  box-shadow: darkgrey 10px 10px 40px 1px;
}

.bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}
</style>
